﻿using System;
using System.Collections.Generic;
using System.Text;

namespace AMS.UI.Menu
{
    public class MenuItemInfo
    {
        /// <summary>
        /// 菜单名称，索引名
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 菜单标题
        /// </summary>
        public string Caption { get; set; }
        /// <summary>
        /// 图片路径，所在的本地文件的路径，它与ImageName分开使用，如果两者都有值优先取这个值
        /// </summary>
        public string ImagePath { get; set; }
        /// <summary>
        /// 图片在资源库中的名称，它与ImagePath分开使用
        /// </summary>
        public string ImageName { get; set; }
        /// <summary>
        /// 是否被选中
        /// </summary>
        public bool Checked { get; set; }
        /// <summary>
        /// [非XML节点]是否已授权
        /// </summary>
        public bool IsAuthorized { get; set; }
        private List<MenuItemInfo> subItems;
        /// <summary>
        /// 子菜单
        /// </summary>
        public List<MenuItemInfo> SubItems
        {
            get
            {
                if (subItems == null)
                {
                    subItems = new List<MenuItemInfo>();
                }

                return subItems;
            }
        }

        /// <summary>
        /// 检查是否有子项
        /// </summary>
        /// <returns></returns>
        public bool HasSubItems()
        {
            return subItems != null && subItems.Count > 0;
        }
    }
}
